<template>
  <div>
    <a-card class="fd-product-num">
      <div>
        <a-form layout="horizontal">
          <div class="fold">
            <a-row >
              <a-col class="fd-product-col" :span="8">
                <div class="tabs-uhn">总数 <br><span style="color: #0182FE">1000</span></div>
                <a-divider class="fd-product-adivider" type="vertical" />
              </a-col>
              <a-col class="fd-product-col" :span="8">
                <div class="tabs-uhn">已启用 <br><span style="color: #04D8B7">10</span></div>
                <a-divider class="fd-product-adivider" type="vertical" />
              </a-col>
              <a-col class="fd-product-col" :span="8">
                <div class="tabs-uhn">未启用 <br><span style="color: #BBBBBB">990</span></div>
              </a-col>
            </a-row>
          </div>
        </a-form>
      </div>
    </a-card>
    <a-card>
      <div>
        <div class="fd-product-search">
          <a-row>
            <a-col class="fd-list-title" :span="8">
              MZ1配方列表
            </a-col>
            <a-col :span="6" :offset="10" >
              <a-input v-model="queryInfo" placeholder="请输入配方ID/产品编码查询" style="width: 100%" @change="query">
                <a-icon slot="prefix" type="search" />
              </a-input>
            </a-col>
          </a-row>
        </div>
        <div>
          <standard-table
                  :columns="columns"
                  :dataSource="dataSource">
            <div slot="action" slot-scope="{text, record}">
              <a-button type="link">下发配方</a-button>
              <a-button type="link">下发参数</a-button>
              <a-button type="link">注册校验</a-button>
              <a-button type="link">参数校验</a-button>
              <router-link :to="`puFormualDetail/detail/${record.PPID}`" >详情</router-link>
            </div>
          </standard-table>
        </div>
      </div>
    </a-card>
  </div>
</template>

<script>
import StandardTable from '@/components/table/StandardTable'
import {getProductList} from '@/services/product'
import {debounce} from "@/utils/debounce"

const columns = [
  {
    title: 'PPID',
    dataIndex: 'no'
  },
  {
    title: '产品编码',
    dataIndex: 'description',
    scopedSlots: { customRender: 'description' }
  },
  {
    title: '创建时间',
    dataIndex: 'updatedAt',
    sorter: true
  },
  {
    title: '创建人',
    dataIndex: 'creator',
  },
  {
    dataIndex: '状态',
    needTotal: true,
    slots: {title: 'statusTitle'}
  },
  {
    title: '操作',
    scopedSlots: { customRender: 'action' }
  }
]

const dataSource = []

for (let i = 0; i < 100; i++) {
  dataSource.push({
    key: i,
    no: 'NO000000000000000 ' + i,
    description: '这是一段描述',
    callNo: Math.floor(Math.random() * 1000),
    status: Math.floor(Math.random() * 10) % 4,
    updatedAt: '2018-07-26',
    creator: 'admin'
  })
}

export default {
  name: 'ProductForm',
  components: {StandardTable},
  data () {
    return {
      columns: columns,
      dataSource: dataSource,
      queryInfo: ''
    }
  },
  watch: {
  },
  mounted() {
    const that = this;
    that.init();
  },
  methods: {
    init() {
      getProductList().then(res => {
        console.info('获取配方列表：', res);
      })
    },
    query: debounce(function() {
      const that = this;
      let filter = {};
      let params = {};
      let conditions = {};
      conditions.contains = that.queryInfo;
      filter.name = conditions;
      params.filter = filter;
      console.info("debounce", that.queryInfo)
      getProductList(params).then(res => {
        console.info('输入框查询结果：', res);
      })
    }, 1000)
  }
}
</script>

<style lang="less" scoped>
  .fd-product-num {
    height: 124px;
    margin-bottom: 20px;
    &/deep/ .ant-card-body {
      padding: 0 24px;
    }
  }
  .fd-product-search{
    margin-bottom: 15px;
    .fd-list-title {
      font-size: 18px;
      font-family: PingFangSC-Semibold, PingFang SC;
      font-weight: 600;
      color: #333333;
    }
  }
  .fold{
    width: 100%;
    display: inline-block;
    .fd-product-col {
      position: relative;
      height: 122px;
      .tabs-uhn{
        width: 70%;
        height: 60px;
        margin-top: 5px;
        margin-left: 15%;
        text-align: center;
        padding:12px 0px;
        background-color: #FFFFFF;
        span {
          font-size: 48px;
          font-family: DINAlternate-Bold, DINAlternate;
          font-weight: bold;
        }
      };
      .fd-product-adivider {
        height: 60px;
        position: absolute;
        right: 0;
        top: 31px;
      }
    }
  }
  .operator{
    margin-bottom: 18px;
  }
  @media screen and (max-width: 900px) {
    .fold {
      width: 100%;
    }
  }
</style>
